Skip to content

refactor(plugins): load OpenCode adapters from managed packages - #1525

Merged
limityan merged 1 commit into
GCWing:mainfrom
limityan:yanzhn/plugin-managed-package-host-input
Jul 13, 2026
Merged

refactor(plugins): load OpenCode adapters from managed packages#1525
limityan merged 1 commit into
GCWing:mainfrom
limityan:yanzhn/plugin-managed-package-host-input

Conversation

@limityan

@limityan limityan commented Jul 13, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Replace the public OpenCode workspace-scanning factory with one factory that consumes validated BitFun-managed package input.
  • Load only the selected managed package after source approval, preserving containment, no-follow, hash, operation-budget, and final trust checks without letting unrelated invalid packages block the read.
  • Keep source approval separate from Host activation: managed inputs remain unactivated read-only projections and cannot produce effects.
  • Align the product architecture, composition-root sequence, Host design, OpenCode audit, module guidance, and boundary checks with the implemented scope.

Behavior and boundaries

  • Production Product Assembly binding, activation UI, Host trust issuance, JS/TS execution, npm installation, hooks/events, and final tool registration remain out of scope.
  • Existing user or global OpenCode directories are not scanned. A future import flow must convert them into the same managed-package format.
  • PluginPackageInput validates manifest/source identity, exact file set, per-file and package size limits, and hashes. It is self-consistent input, not an approval credential.
  • Selected-package reads ignore unrelated package content, serialize retained-content loads per service instance, and report transient capacity, trust-store, and trust-race failures as retryable unavailability.
  • Local, npm, invalid-config, and empty-package projections use bounded source-derived IDs with a 128-bit digest; duplicate npm declarations are removed.
  • Packages with no supported OpenCode entry return a typed diagnostic instead of an empty projection.
  • Current source inspection is limited to the tested single-line declaration subset. It is not a general JavaScript or TypeScript parser, and other syntax is outside this PR's compatibility claim.
  • Invalid external content remains diagnosable and cannot crash, execute code, or produce effects.

Resource and code-size impact

Metric Before After
Public OpenCode adapter factories 1 workspace scanner 1 managed-package factory
Adapter filesystem scans workspace/config/plugin files 0
Selected package load full package-content scan target package content only
Fixed-input limits adapter-local 1 MiB source check 1 MiB/file, 16 MiB/package
Concurrent retained-content loads unbounded/not available 1 per service instance
Operation budget not available shared 256 MiB / 30 s
Final diff - +1399 / -1085, net +314 lines

Verification

  • cargo +nightly test -p bitfun-product-domains --test plugin_source_contracts --features plugin-source (7 passed)
  • cargo +nightly test -p bitfun-services-integrations --no-default-features --features plugin-source plugin_source --lib (40 passed)
  • cargo +nightly test -p bitfun-opencode-adapter (30 passed: 15 unit + 15 Host integration)
  • node --test scripts/check-core-boundaries.test.mjs (3 passed)
  • node scripts/check-core-boundaries.mjs
  • pnpm run check:repo-hygiene
  • cargo +nightly check --locked --workspace --exclude bitfun-cli
  • git diff --check

The workspace check retains pre-existing Windows unsafe-op-in-unsafe-fn warnings and introduces no new warning class.

Independent review

Fresh isolated architecture/product and Rust security/performance reviewers audited the rebased full diff. Findings covering composition-root direction, empty projections, source-ID collisions, target-load isolation, retryable error semantics, misleading candidate documentation, and unnecessary reconciliation parameters were fixed. After the scope was explicitly limited to managed fixed input and read-only diagnostics, both reviewers reported no remaining P0/P1/P2 findings.

Replace direct workspace scanning with validated fixed package input, isolate selected-package reads, and keep source approval separate from Host activation.
@limityan
limityan force-pushed the yanzhn/plugin-managed-package-host-input branch from 85faa10 to 840fa27 Compare July 13, 2026 04:55
@limityan
limityan merged commit 34ccfb3 into GCWing:main Jul 13, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant